package cn.edu.besti.cs2023.W2321;
public class newSorting_Maru {
    public int[] selectionSort(int[] data)
    {
        int min=0;
        for(int i=0;i<data.length;i++)
        {

            for (int j=i+1;j<data.length;j++)
            {
                if(data[i]>data[j])
                {min=data[j];
                    data[j]=data[i];
                    data[i]=min;}

            }

        }
        return data;

    }
    public int[] insertSort(int []data)
    {
        int temp;
        int j ;
        for(int i=1;i<data.length;i++)
        {
            temp=data[i];
            for ( j=i-1;j>=0&&data[j]>=temp;j--)
            {
                data[j+1]=data[j];
            }
            data[j+1]=temp;

        }
        return data;

    }

    public  int[] shellSort(int[] data)
    {
        int j = 0;
        int temp = 0;
        for (int increment = data.length / 2; increment > 0; increment /= 2)
        {
            for (int i = increment; i < data.length; i++)
            {
                temp = data[i];
                for (j = i; j >= increment&&temp <data[j - increment]; j -= increment)
                {
                    data[j] = data[j - increment];
                }
                data[j] = temp;
            }

        }
        return data;

    }

}

